use crate::volcengine;

/// Tauri 命令：翻译文本
#[tauri::command]
pub async fn translate(
    text: String,
    source_lang: String,
    target_lang: String,
) -> Result<volcengine::TranslationResponse, String> {
    // 在此处安全地获取您的密钥
    // 推荐使用环境变量或Tauri的安全存储
    let access_key = "AKLTNjA5NGUxYTY1YWY0NDgzMzg4YzMzYmZlNGU0NmEwODk";
    let secret_key = "TnpSak5tSmxPRGRrT1RKa05ESTVZemhrT0RFeFpUUm1ZVGN5TnpBME1HUQ==";

    match volcengine::translate(&access_key, &secret_key, &text, &source_lang, &target_lang).await {
        Ok(resp) => Ok(resp),
        Err(e) => Err(e.to_string()),
    }
}

